/**
 * Created with IntelliJ IDEA.
 * Description:自定义异常
 * User: dings
 * Date: 2024-04-28
 * Time: 13:19
 */
class MyException extends Exception{

    public MyException() {
    }
    public MyException(String message) {
        super(message);
    }
}
public class Test2 {
    public static void func(int a) throws MyException{
        if(a == 10) {
            throw new MyException("123");
        }
    }

    public static void main(String[] args) {
        try {
            func(10);
        }catch (MyException e) {
            e.printStackTrace();
        }
    }
}
